﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 访问者模式.Visitor;

namespace 访问者模式
{
    //违背封装
    /// <summary>
    /// 1 集合的访问和访问者模式Visitor Pattern
    /// 2 倾斜的可扩展性设计
    /// 3 应用场景
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            List<Student> students = new List<Student>() {
           new StudentVip(){
               Id=1888,
               Name="大黄瓜"
           },
            new StudentFree(){
               Id=2888,
               Name="大黄瓜2"
           }};

            //foreach (var item in students)
            //{
            //    item.Study();
            //    item.GetVideo();
            //}
            {
                Console.WriteLine("*****************VisitorCurrent************");
                VisitorCurrent visitorCurrent = new VisitorCurrent();
                foreach (var item in students)
                {
                    item.Study();
                    item.GetVideoVisitor(visitorCurrent);
                }
            }

            {
                Console.WriteLine("*****************VisitorPast************");
                VisitorPast visitorPast = new VisitorPast();
                foreach (var item in students)
                {
                    item.Study();
                    item.GetVideoVisitor(visitorPast);
                }
            }
            Console.Read();
        }
    }
}
